package org.apache.commons.graph.bean

import com.gitee.wsl.text.format.format
import org.apache.commons.graph.utils.Objects

/**
 * Indicates a vertex pair.
 *
 * @param <V> the Graph vertices type
</V> */

class VertexPair<V>(
    val head: V,
    val tail: V
)  {

    /**
     * {@inheritDoc}
     */
    override fun equals(other: Any?): Boolean {
        if (this === other) {
            return true
        }
        if (other == null || this::class != other::class) {
            return false
        }
        other as VertexPair<*>
        return Objects.eq(head, other.head)
                && Objects.eq(tail, other.tail)
    }

    /**
     * {@inheritDoc}
     */
    override fun hashCode(): Int {
        val prime = 31
        return Objects.hash(1, prime, head, tail)
    }

    override fun toString(): String {
        return String.format("[head=%s, tail=%s]", head, tail)
    }

}